<?php


namespace App\Models\ProductCenter;


use App\Models\BaseModel;

class ProductModel extends BaseModel
{
    public $connection = 'productCenter';
    public $dateFormat = 'U';

    public function getWhereByStoreId($where)
    {
        $storeId = $this->getCurrentStoreId();
        if (!$storeId) {
            throwError([404, 'store_id不存在']);
        }
        $where['store_id'] = $this->getCurrentStoreId();

        return $where;
    }

    public function getInfo($where)
    {
        $where = $this->getWhereByStoreId($where);
        return parent::getInfo($where);
    }

    public function getListByPage($where = [], $columns = ['*'], $pageSize = self::PAGE_SIZE, $orderBy = 'id desc')
    {
        $where = $this->getWhereByStoreId($where);
        return parent::getListByPage($where, $columns, $pageSize, $orderBy);

    }

    public function getList($where = [], $field = '*', $orderBy = 'id desc')
    {
        $where = $this->getWhereByStoreId($where);
        return parent::getList($where, $field, $orderBy); // TODO: Change the autogenerated stub
    }

    public function getFirst($where = [], $field = '*')
    {
        $where = $this->getWhereByStoreId($where);
        return parent::getFirst($where, $field); // TODO: Change the autogenerated stub
    }

    public function editItem($where, $data)
    {
        $where = $this->getWhereByStoreId($where);
        return parent::editItem($where, $data); // TODO: Change the autogenerated stub
    }

    public function addItem($data, $boolean = false)
    {
        $data = $this->getWhereByStoreId($data);
        return parent::addItem($data, $boolean); // TODO: Change the autogenerated stub
    }
}
